package com.siyuanren.gcocp.mapper;


import com.siyuanren.gcocp.dto.*;
import com.siyuanren.gcocp.dto.wx.WxUserInviteCourseDTO;
import com.siyuanren.gcocp.entity.WxCourse;
import com.siyuanren.gcocp.entity.WxCourseStart;
import com.siyuanren.gcocp.mapper.base.WxCourseMapper;
import com.siyuanren.gcocp.vo.*;

import java.util.List;

/**
 * Created by   anxing
 * Project_name gcocp-parent
 * Path         com.siyuanren.gcocp.dao.wx.base
 * Date         2018/4/11
 * Time         11:52
 * Description
 */
public interface  MyWxCourseMapper extends WxCourseMapper{

    /**
     * 返回推荐课程
     * @return
     * @throws Exception
     *         SELECT DISTINCT c.id course_id, c.*,  t.`teacher_img`, t.`teacher_name`
    FROM wx_course_category cc, wx_teacher t, wx_course c
    WHERE cc.id=#{categoryId} AND c.`course_category`=cc.`id` AND c.`teacher_id`=t.`id` AND c.`available`=1 ORDER BY c.id DESC

     */
    public List<WxCategoryDTO> getRecommendCourses(Integer userId) throws Exception;

    /**
     * 返回用户课程
     * @param courseVO
     * @return
     * SELECT c.id course_id, c.*, tea.`teacher_name`, tea.`teacher_img`, uc.grad_time, uc.`course_start_id`
    FROM    wx_user_course uc, wx_teacher tea, wx_course c
    WHERE
    c.id = uc.`course_id`
    AND uc.user_id=50
    AND c.`teacher_id` = tea.`id`
    AND uc.`available`=1
     */
    public List<WxCourseDTO> getUserCourseList(QueryUserCourseVO courseVO) throws Exception;
    /**
     * 返回用户邀请课程列表
     * @param userId
     * @return
     * @throws Exception
     * SELECT u.`user_name`, u.`user_img`, c.course_name, c.`course_desc`, c.invite_voucher_id, c.`course_target`, c.`invite_bg_color`, c.`invite_img`, uc.*
    FROM wx_user_course uc, wx_course c, wx_user u
    WHERE u.id=50 AND uc.`user_id`=u.id AND uc.`course_id`=c.id
    AND uc.`available`=1
     */
    List<WxUserInviteCourseDTO> getUserInviteCourseList(Integer userId) throws Exception;
    /**
     * 返回课程学分
     * SELECT c.*, uc.course_score user_score FROM wx_course c, wx_user_course uc WHERE c.id = uc.course_id AND uc.user_id=1  AND c.id=1
     * @param queryUserCourseDetailVO
     * @return
     */
    public CourseScoreDTO getCourseScore(QueryUserCourseDetailVO queryUserCourseDetailVO) throws Exception;

    /**
     * 返回用户毕业信息
     * @param queryGradVO
     * SELECT * FROM wx_user u, wx_user_course uc, wx_course c
    WHERE u.`id` = 1 AND c.id=1 AND uc.`user_id`=u.`id` AND uc.`course_id` = c.`id`
     * @return
     * @throws Exception
     */
    public CourseGradDTO getCourseGrad(QueryGradVO queryGradVO) throws Exception;

    /**
     * 查询用户开课信息
     * @param queryUserCourseStartVO
     * @return
     * SELECT cs.* FROM wx_user_course uc, wx_course_start cs WHERE uc.user_id=1 AND uc.course_id=1 AND uc.`course_start_id`=cs.`id`
     */
    public List<WxCourseStart> getUserCourseStart(QueryUserCourseStartVO queryUserCourseStartVO);

    /**
     * 根据id查询课程
     * @param id
     * @return
     *SELECT c.*, t.`teacher_img`, t.`teacher_name`
    FROM wx_teacher t, wx_course c

    WHERE c.`teacher_id`=t.`id`  AND c.id=1
     */
    WxCourseTeaDTO getById(int id);

    /**
     * 返回活动邀请用户可以购买的课程
     * @param activeId
     */
    WxCourse getActiveFollowCourse(Integer activeId);
    /**
     * 返回活动赠送给邀请者的课程
     * @param activeId
     */
    WxCourse getActiveSponsorCourse(Integer activeId);

    /**
     * 获取微信入群二维码
     * @param queryWxGroup
     * @return
     * SELECT qr.* FROM wx_group_qrcode qr, wx_user_course uc
    WHERE uc.`user_id`=1 AND uc.`course_id`=1 AND qr.`course_start_id`=uc.`course_start_id`
    AND qr.`available`=1 AND qr.`is_full`=0
     */
    List<WxGroupQrcodeDTO> getWxGroupQrcode(QueryWxGroupVO queryWxGroup);

    /**
     * 查询课程详情页面
     * @param queryDetailVO
     * @return
     *         SELECT DISTINCT c.*, t.`teacher_img`, t.`teacher_name`
    FROM wx_teacher t, wx_course c
    WHERE c.id=26 AND c.`teacher_id`=t.`id`
     */
    CourseDetailDTO getCourseDetail(QueryCourseDetailVO queryDetailVO);

    /**
     * 根据课程类别查询课程
     * @param vo
     * @return
     * SELECT DISTINCT c.id course_id, c.*,  t.`teacher_img`, t.`teacher_name`
    FROM wx_course_category cc, wx_teacher t, wx_course c
    WHERE cc.id=1 AND c.`course_category`=cc.`id` AND c.`teacher_id`=t.`id` AND c.`available`=1 ORDER BY c.sort
     */
    List<WxCourseDTO> getCourseByCategory(QueryCourseByCategoryVO vo);
}
